<!---removes old file and cleans up directory if it is empty--->
<cfquery name="qold" datasource="#request.dsn#">
SELECT * FROM blog_posts WHERE b_id = <cfqueryparam value="#b_id#" cfsqltype="cf_sql_integer">
</cfquery>
<cfloop query="qold">
	<!---remove the file--->
	<cfif fileexists('#request.basepath#blog/#b_year#/#b_month#/#b_day#/#b_file#')>
        <cffile action="delete" file="#request.basepath#blog/#b_year#/#b_month#/#b_day#/#b_file#">
    </cfif>
    <!---remove the directory if it's empty--->
    <cfif directoryexists('#request.basepath#blog/#b_year#/#b_month#/#b_day#')>
        <cfdirectory action="list" directory="#request.basepath#blog/#b_year#/#b_month#/#b_day#" name="qfolder">
        <cfif qfolder.recordcount IS 0>
            <cfdirectory action="delete" directory="#request.basepath#blog/#b_year#/#b_month#/#b_day#">		
        </cfif>
    </cfif>
</cfloop>